﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace gvPoco.Data
{
    public class DataTable
    {

        public List<Column> cols { get; set; }
        public List<Row> rows { get; set; }
        public bool hasData { get; set; }

        public DataTable()
        {
            cols = new List<Column>();
            rows = new List<Row>();
        }

        public void AddColumn(string columnLabel, string columnType, string columnId = "")
        {
            cols.Add(new Column() { label = columnLabel, type = columnType, id = columnId });
        }

        public void AddRow(params dynamic[] rowValues)
        {
            Row row = new Row();
            
            int length = rowValues.Length;
            for (int i = 0; i < length; i++)
            {
                row.c.Add(new Cell() { v = rowValues[i] });
            }

            rows.Add(row);
        }
    }
}